***********************************************************************************************
**	Title:   Extortion, Civic Action, and Political Participation among Guatemalan Deportees
**	Authors: Elaine Denny, David A. Dow, Gabriella Levy, Mateo Villamizar Chaparro
**  Journal: British Journal of Political Science
**	Date:    May 2023
**************************************************************************************************

clear
set more off

** Install additional packages
ssc install icw_index
ssc install balancetable
ssc install rwolf
*ssc install blindschemes
*ssc install outreg

** set scheme 
set scheme plottig

*Load data (change your data input directory below)
global input "~\Dropbox\Denny, Dow, Levy, Villamizar Chaparro\Replication BJPS"
use "$input\gt_extortion_rep_data_v2.dta", clear

** set directory to output folder
cd "~\Dropbox\Denny, Dow, Levy, Villamizar Chaparro\Replication BJPS\output" 

** apply relevant Round 1 variables to Rounds 2 and 3 for analysis
sort id_survey round
local r1vars female age indigenous ln_timeus edu_highest_panel children_gt_panel children_us_panel assets border coyote_yes coyote_in_dum assault_dum extortion_dum tattoo_yes

foreach v in `r1vars' {
	bysort id_survey: carryforward `v', replace
}

** define controls 
global controls female age indigenous edu_highest_panel tattoo_yes children_us_panel children_gt_panel loc_social_cf ln_timeus assets employed
global controls_econ female age indigenous edu_highest_panel tattoo_yes children_us_panel children_gt_panel loc_social_cf ln_timeus assets


** generate average political & civic indices 
gen civic_action_only = (comm_meeting_panel + volunteer_panel + mentor_panel)/3
gen political_action_only = (protest_panel + affparty_panel + vote_panel)/3

label var civic_action_only "Civic Action Index"
label var political_action_only "Political Action Index"


** List of Tables and Figures
	** Table 1: Extortion During Migration - Arrival Survey Responses 
	** Figure 1: Extortion Predicts Poor Outcomes: Fear of Crime and Economic Hardship (mechanisms_plot.pdf)
	** Figure 2: Mediation Analysis: Extortion and Fear of Crime on Citizen Engagement}{graphics/med_fear_combine.pdf}
	** Figure 3: Mediation Analysis: Extortion and Economic Hardship on Citizen Engagement}{graphics/med_econ_combine.pdf} \\  

** Appendix figures
	** Table A3: Summary Statistics
	** Table A4: Attrition after Arrival Survey
	** Table A5: Survey Attrition & Personality from Rounds 2 to 3
	** Table A6: Extortion During Migration - Follow-Up Respondents Only
	** Table A7: Using Coyote to Attempt Entry
	** Table A8: Extortion Predicts Poor Outcomes - Fear and Economic Hardship (table_mech.tex)
	** Table A9: Extortion Predicts Poor Outcomes: Economic and Safety (table_mech_robustness)
	** Table A10: Extortion and Fear of Crime Mediation Analysis (mediation_fear_regs)
	** Table A11: Extortion and Economic Hardship Mediation Analysis (mediation_econ_regs)
	** Table A12: Extortion and Engagement Items Disaggregated (ext_disaggregate)
	** Table A13: Extortion and Engagement - Robustness Checks (mediation_fear_regs_robustness)
	** Table A14: Assault Not Correlated with Engagement (assault_regs)
	** Table A15: Romano-Wolf Adjusted p-values for Extortion Variable (rw_extortion)
	** Table A16: Descriptive Statistics by Migratory Status LAPOP (2018/19)
	** Figure A3: Democracy and Institutionalization index (top quartile) with returnees from the EU and USA


** Dependent variables
local d_civic comm_meeting_panel volunteer_panel mentor_panel
local d_pol protest_panel affparty_panel vote_panel


gen sample = 1 if civic_action_only != . & comm_meeting_panel != . & volunteer_panel != . & mentor_panel != . & political_action_only != . & protest_panel != . & affparty_panel != . & vote_panel != .
 
********************************************************************************
** 						Balance and Attrition Tables
********************************************************************************

********************************************************************************
** Table 1: Extortion During Migration - Arrival Survey Responses (balance_extortion_arrival)
********************************************************************************

balancetable extortion_dum age indigenous female edu_highest_panel married children_gt_panel children_us_panel border ln_timeus migrations_num tattoo_yes us_return_all visit_rel_all using "table1_balance_extortion_arrival.tex" if round == 1, varlabels ctitles("No Extortion" "Extortion" "Difference") starlevels(+ .1 * .05 ** .01) prehead("\begin{table}[h!]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Extortion During Migration - Arrival Survey Responses\label{tab:extortion}} \footnotesize \begin{tabular}{l*{3}c} \hline\hline") postfoot("\hline\hline \multicolumn{4}{l}{\scriptsize Notes: Difference between group means in two-tailed t-test} \\ \multicolumn{4}{l}{\scriptsize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)} \\ \end{tabular} \end{table}") replace 


********************************************************************************
 ** Table A4: Attrition after Arrival Survey (r1_attrition.tex) 
********************************************************************************
egen rounds_participated = count(id_survey), by(id_survey)
gen follow_sample = 0 if rounds_participated == 1
replace follow_sample = 1 if rounds_participated > 1

balancetable follow_sample extortion_dum age indigenous female edu_highest_panel married children_gt_panel children_us_panel border ln_timeus migrations_num tattoo_yes us_return_all visit_rel_all recent_econ recent_expect using "table_a4_r1_attrition.tex" if round == 1, varlabels ctitles("Dropped Out" "Panel Sample" "Difference") starlevels(+ .1 * .05 ** .01) prehead("\begin{table}[htbp]\centering\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \footnotesize \caption{Attrition after Arrival Survey\label{tab:r1attrition}} \begin{tabular}{l*{3}c} \hline\hline") postfoot("\hline \hline \multicolumn{4}{l}{\scriptsize Notes: Displays differences between group means in two-tailed t-test} \\ \multicolumn{4}{l}{\scriptsize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)} \\ \end{tabular} \end{table}") replace


********************************************************************************
** Table A5: Survey Attrition & Personality from Rounds 2 to 3
********************************************************************************
egen round2_participant = max(round2), by(id_survey)
egen round3_participant = max(round3), by(id_survey)
gen round3_response = 0 if round2_participant == 1 & round3_participant == 0
replace round3_response = 1 if round2_participant == 1 & round3_participant == 1

balancetable round3_response r2reserved r2critical r2anxious using "table_a5_r3_attrition.tex" if round == 2, varlabels ctitles("Dropped Out After R2" "Round 3 Sample" "Difference") starlevels(+ .1 * .05 ** .01) prehead("\begin{table}[htbp]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \footnotesize \caption{Survey Attrition \& Personality from Rounds 2 to 3\label{tab:r3attrition}} \begin{tabular}{l*{3}c} \hline\hline") postfoot("\hline\hline \multicolumn{4}{l}{\scriptsize Notes: Personality variables only measured in round 2 of follow-up survey}\\ \multicolumn{4}{l}{\scriptsize Displays differences between group means in two-tailed t-test} \\ \multicolumn{4}{l}{\scriptsize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)} \\ \end{tabular} \end{table}") replace
 
********************************************************************************
** Table A6: Extortion During Migration - Follow-Up Respondents Only
********************************************************************************
** Run basic model to get follow-up analysis sample
egen zfear_count = std(fearcount_general)
label var zfear_count "Fear of Crime"
qui regress civic_action_only extortion_dum zfear_count $controls border round3, vce(cluster id_survey)
gen sample_table = e(sample)
egen sample_table_cs = max(sample_table), by(id_survey)

** add personality variables measured in round 2 only
egen r2critical_cs = max(r2critical), by(id_survey)
egen r2reserved_cs = max(r2reserved), by(id_survey)
egen r2anxious_cs = max(r2anxious), by(id_survey)

label var r2critical_cs "Critical"
label var r2reserved_cs "Reserved"
label var r2anxious_cs "Anxious"

** avg social network response over rounds 2 and 3
egen loc_social_avg = mean(loc_social_cf), by(id_survey)
label var loc_social_avg "Local Social Network (Avg)"


** Table A6
balancetable extortion_dum age indigenous female edu_highest_panel married children_gt_panel children_us_panel border ln_timeus migrations_num tattoo_yes us_return_all visit_rel_all loc_social_avg r2critical_cs r2reserved_cs r2anxious_cs using "table_a6_balance_extortion_followups.tex" if round == 1 & sample_table_cs==1, varlabels ctitles("No Extortion" "Extortion" "Difference") starlevels(+ .1 * .05 ** .01) prehead("\begin{table}[h!]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \footnotesize \caption{Extortion During Migration - Follow-Up Respondents Only\label{tab:ext_follow}} \begin{tabular}{l*{3}c} \hline\hline") postfoot("\hline\hline \multicolumn{4}{l}{\scriptsize Notes: Displays differences between group means in two-tailed t-test} \\ \multicolumn{4}{l}{\scriptsize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)} \\ \end{tabular} \end{table}") replace
 
 
******************************************************************************** 
** 	Table A7: Using Coyote to Attempt Entry
********************************************************************************
balancetable coyote_in_dum age indigenous female edu_highest_panel married children_gt_panel children_us_panel border ln_timeus migrations_num tattoo_yes using "table_a7_balance_coyote_arrival.tex" if round == 1, varlabels ctitles("No Coyote In" "Coyote Into US" "Difference") starlevels(+ .1 * .05 ** .01) prehead("\begin{table}[h!]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Using Coyote to Attempt Entry\label{tab:coyote}} \footnotesize \begin{tabular}{l*{3}c} \hline\hline") postfoot("\hline\hline \multicolumn{4}{l}{\scriptsize Notes: Displays differences between group means in two-tailed t-test} \\ \multicolumn{4}{l}{\scriptsize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)} \\ \end{tabular} \end{table}") replace
 

********************************************************************************
***	Economic and fear outcomes
********************************************************************************
** econ and fear summary indices
egen zmonthly_income = std(monthly_income)
replace zmonthly_income = -1*zmonthly_income

egen zunemployed = std(current_unemployed)
egen zhardship_guat = std(hardship_guat)
egen zecon_now = std(econ_now)

* to generate summary index 
* icw_index zmonthly_income zunemployed zhardship_guat zecon_now, gen(econ_summary_index)
egen zecon_summary_index = std(econ_summary_index)


	** Figure 1: Extortion Predicts Poor Outcomes: Fear of Crime and Economic Hardship (mechanisms_plot.pdf)
eststo clear
eststo: qui regress zfear_count extortion_dum $controls border round3,  vce(cluster id_survey)
eststo: qui regress zecon_summary_index extortion_dum $controls_econ border round3,  vce(cluster id_survey)

coefplot (est1 \ est2), keep(extortion_dum) title("") aseq swapnames coeflabels(est1 = "Fear of Crime (Count)" est2 = "Economic Hardship Index") xlabel(-0.2(0.2)0.6) xscale(range(-0.2 0.6)) xline(0, lcolor(black)) level(95 90) ytitle(Dependent Variables (Standardized)) xtitle(Coefficient for Extortion Variable)
graph export "fig1_mechanisms_plot.pdf", replace


	** Table A8: Extortion Predicts Poor Outcomes - Fear and Economic Hardship (table_mech.tex)
eststo clear
eststo: qui regress zfear_count extortion_dum $controls border round3,  vce(cluster id_survey)
eststo: qui regress zecon_summary_index extortion_dum $controls_econ border round3,  vce(cluster id_survey)
esttab using "table_a8_mech.tex", label nogap b(2) se(2)  title(Extortion Predicts Poor Outcomes: Economic and Safety\label{tab:mech})  mtitle("Fear of Crime" "Econ Hardship Index") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent" "Standardized DVs for each model") replace


	** Table A9: Extortion Predicts Poor Outcomes: Economic and Safety (table_mech_robustness)
eststo clear
eststo: qui nbreg fearcount_general extortion_dum $controls border round3,  vce(cluster id_survey)
estadd local model "Neg. Binomial", replace
eststo: qui logit fear_any extortion_dum $controls border round3,  vce(cluster id_survey)
estadd local model "Logit", replace
eststo: qui regress zmonthly_income extortion_dum $controls_econ border round3,  vce(cluster id_survey)
estadd local model "OLS", replace
eststo: qui logit current_unemployed extortion_dum $controls_econ border round3,  vce(cluster id_survey)
estadd local model "Logit", replace
eststo: qui regress zhardship_guat extortion_dum $controls_econ border round3,  vce(cluster id_survey)
estadd local model "OLS", replace
eststo: qui regress zecon_now extortion_dum $controls_econ border round3,  vce(cluster id_survey)
estadd local model "OLS", replace
eststo: qui regress barr_debt extortion_dum border female age indigenous edu_highest_panel tattoo_yes children_us_panel children_gt_panel assets ln_timeus if round==1 , robust
estadd local model "OLS", replace

esttab using table_a9_mech_robustness.tex, label nogap b(2) se(2)  title(Extortion Predicts Poor Outcomes: Economic and Safety\label{tab:mechrobust})  mtitle("Fear of Crime (Count)" "Fear of Crime (Any)" "Monthly Income" "Currently Unemployed" "Econ Difficulties" "Econ Situation (Bad)" "Debt Barrier") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent") scalar("model Model") replace


********************************************************************************
***  Mediation analysis
********************************************************************************

************************************************************************************
*** Figure 2: Mediation Analysis: Extortion and Fear of Crime on Citizen Engagement (med_fear_combine.pdf)
************************************************************************************

** Fear Mediator - Civic Action Outcome: 
** 90% confidence interval
qui: medeff (regress zfear_count extortion_dum  border  round3  $controls) (regress civic_action_only zfear_count extortion_dum border  round3 $controls), treat(extortion_dum) mediate(zfear_count) sims(2000) seed(1) level(90) vce(cluster id_survey)

matrix medmean_fc = J(1,3,.)
matrix colnames medmean_fc = ACME Direct Total
matrix medmean_fc[1, 1] = r(delta0)
matrix medmean_fc[1, 2] = r(zeta0)
matrix medmean_fc[1, 3] = r(tau)

matrix CI90_fc = J(2,3,.)
matrix colnames CI90_fc = ACME Direct Total
matrix CI90_fc[1, 1] = r(delta0lo)
matrix CI90_fc[1, 2] = r(zeta0lo)
matrix CI90_fc[1, 3] = r(taulo)
matrix CI90_fc[2, 1] = r(delta0hi)
matrix CI90_fc[2, 2] = r(zeta0hi)
matrix CI90_fc[2, 3] = r(tauhi)

** 95% confidence interval
qui: medeff (regress zfear_count extortion_dum  border  round3  $controls) (regress civic_action_only zfear_count extortion_dum border  round3 $controls), treat(extortion_dum) mediate(zfear_count) sims(2000) seed(1) level(95) vce(cluster id_survey)

matrix CI95_fc= J(2,3,.)
matrix colnames CI95_fc = ACME Direct Total
matrix CI95_fc[1, 1] = r(delta0lo)
matrix CI95_fc[1, 2] = r(zeta0lo)
matrix CI95_fc[1, 3] = r(taulo)
matrix CI95_fc[2, 1] = r(delta0hi)
matrix CI95_fc[2, 2] = r(zeta0hi)
matrix CI95_fc[2, 3] = r(tauhi)

coefplot matrix(medmean_fc), ci(CI95_fc CI90_fc) xline(0, lcolor(black)) title(Civic Action Outcome; Fear Mediator) xtitle(Effect on Civic Action Index) xlabel(-0.2(0.2)0.4) xscale(range(-0.2 0.4))
graph save med_fear_civic.gph, replace
graph export med_fear_civic.pdf, replace


** Fear Mediator - Political Action Outcome: 
** 90% confidence interval
qui: medeff (regress zfear_count extortion_dum  border  round3  $controls) (regress political_action_only zfear_count extortion_dum border  round3 $controls), treat(extortion_dum) mediate(zfear_count) sims(2000) seed(1) level(90) vce(cluster id_survey)

matrix medmean_fp = J(1,3,.)
matrix colnames medmean_fp = ACME Direct Total
matrix medmean_fp[1, 1] = r(delta0)
matrix medmean_fp[1, 2] = r(zeta0)
matrix medmean_fp[1, 3] = r(tau)

matrix CI90_fp = J(2,3,.)
matrix colnames CI90_fp = ACME Direct Total
matrix CI90_fp[1, 1] = r(delta0lo)
matrix CI90_fp[1, 2] = r(zeta0lo)
matrix CI90_fp[1, 3] = r(taulo)
matrix CI90_fp[2, 1] = r(delta0hi)
matrix CI90_fp[2, 2] = r(zeta0hi)
matrix CI90_fp[2, 3] = r(tauhi)

** 95% confidence interval
qui: medeff (regress zfear_count extortion_dum  border  round3  $controls) (regress political_action_only zfear_count extortion_dum border  round3 $controls), treat(extortion_dum) mediate(zfear_count) sims(2000) seed(1) level(95) vce(cluster id_survey)

matrix CI95_fp = J(2,3,.)
matrix colnames CI95_fp = ACME Direct Total
matrix CI95_fp[1, 1] = r(delta0lo)
matrix CI95_fp[1, 2] = r(zeta0lo)
matrix CI95_fp[1, 3] = r(taulo)
matrix CI95_fp[2, 1] = r(delta0hi)
matrix CI95_fp[2, 2] = r(zeta0hi)
matrix CI95_fp[2, 3] = r(tauhi)

coefplot matrix(medmean_fp), ci(CI95_fp CI90_fp) xline(0, lcolor(black)) title(Political Action Outcome; Fear of Crime (Count)) xtitle(Effect on Political Action Index) xlabel(-0.2(0.2)0.4) xscale(range(-0.2 0.4))
graph save med_fear_political.gph, replace
graph export med_fear_political.pdf, replace

* combine graphs into single plot
graph combine med_fear_civic.gph med_fear_political.gph, ycommon xcommon rows(1)
graph export fig2_med_fear_combine.pdf, replace


**************************************************************************************
** Table A10: Extortion and Fear of Crime Mediation Analysis (mediation_fear_regs)
**************************************************************************************
eststo clear 
eststo: qui regress civic_action_only extortion_dum zfear_count $controls border round3, vce(cluster id_survey)
gen sample_fc = 1 if e(sample) == 1
eststo: qui regress political_action_only extortion_dum zfear_count $controls border round3, vce(cluster id_survey)
gen sample_fp = 1 if e(sample) == 1

eststo clear 
eststo: qui regress zfear_count extortion_dum $controls border round3 if sample_fc == 1, vce(cluster id_survey)
eststo: qui regress civic_action_only extortion_dum zfear_count $controls border round3 if sample_fc == 1, vce(cluster id_survey)
eststo: qui regress zfear_count extortion_dum $controls border round3 if sample_fp == 1, vce(cluster id_survey)
eststo: qui regress political_action_only extortion_dum zfear_count $controls border round3 if sample_fp == 1, vce(cluster id_survey)
esttab using table_a10_mediation_fear_regs.tex, label nogap b(2) se(2)  title(Extortion and Fear of Crime Mediation\label{mediation_fear})  mtitle("Fear of Crime" "Civic Action Index" "Fear of Crime"  "Political Action Index") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent" "All models are OLS Linear Regressions" "Column 1 is first-stage model for civic outcome in Column 2" "Column 3 is first-stage model for political outcome in Column 4") replace




******************************************************************************************
**  Figure 3: Mediation Analysis: Extortion and Economic Hardship on Citizen Engagement (med_econ_combine.pdf)
******************************************************************************************

** Economic Mediation - Civic Action Outcome:
** 90% confidence interval
eststo clear 
eststo: medeff (regress econ_summary_index extortion_dum $controls_econ border  round3) (regress civic_action_only econ_summary_index extortion_dum $controls_econ border  round3), treat(extortion_dum) mediate(econ_summary_index) sims(2000) seed(1) level(90) vce(cluster id_survey)

matrix mean_ec = J(1,3,.)
matrix colnames mean_ec = ACME Direct Total
matrix mean_ec[1, 1] = r(delta0)
matrix mean_ec[1, 2] = r(zeta0)
matrix mean_ec[1, 3] = r(tau)

matrix CI90_ec = J(2,3,.)
matrix colnames CI90_ec = ACME Direct Total
matrix CI90_ec[1, 1] = r(delta0lo)
matrix CI90_ec[1, 2] = r(zeta0lo)
matrix CI90_ec[1, 3] = r(taulo)
matrix CI90_ec[2, 1] = r(delta0hi)
matrix CI90_ec[2, 2] = r(zeta0hi)
matrix CI90_ec[2, 3] = r(tauhi)

** 95% confidence interval
qui: medeff (regress econ_summary_index extortion_dum $controls_econ border  round3) (regress civic_action_only econ_summary_index extortion_dum $controls_econ border round3), treat(extortion_dum) mediate(econ_summary_index) sims(2000) seed(1) level(95) vce(cluster id_survey)

matrix CI95_ec = J(2,3,.)
matrix colnames CI95_ec = ACME Direct Total
matrix CI95_ec[1, 1] = r(delta0lo)
matrix CI95_ec[1, 2] = r(zeta0lo)
matrix CI95_ec[1, 3] = r(taulo)
matrix CI95_ec[2, 1] = r(delta0hi)
matrix CI95_ec[2, 2] = r(zeta0hi)
matrix CI95_ec[2, 3] = r(tauhi)

coefplot matrix(mean_ec), ci(CI95_ec CI90_ec) xline(0, lcolor(black)) title(Civic Action Outcome; Economic Hardship Index) xtitle(Effect on Civic Action Index) xlabel(-0.2(0.2)0.4) xscale(range(-0.2 0.4))
graph save med_econ_civic.gph, replace
graph export med_econ_civic.pdf, replace


** Economic Mediator & Political Action Outcome
** 90% confidence interval
qui: medeff (regress econ_summary_index extortion_dum $controls_econ border round3) (regress political_action_only econ_summary_index extortion_dum $controls_econ border round3), treat(extortion_dum) mediate(econ_summary_index) sims(2000) seed(1) level(90) vce(cluster id_survey)

matrix medmean_ep = J(1,3,.)
matrix colnames medmean_ep = ACME Direct Total
matrix medmean_ep[1, 1] = r(delta0)
matrix medmean_ep[1, 2] = r(zeta0)
matrix medmean_ep[1, 3] = r(tau)

matrix CI90_ep = J(2,3,.)
matrix colnames CI90_ep = ACME Direct Total
matrix CI90_ep[1, 1] = r(delta0lo)
matrix CI90_ep[1, 2] = r(zeta0lo)
matrix CI90_ep[1, 3] = r(taulo)
matrix CI90_ep[2, 1] = r(delta0hi)
matrix CI90_ep[2, 2] = r(zeta0hi)
matrix CI90_ep[2, 3] = r(tauhi)

** 95% confidence interval
qui: medeff (regress econ_summary_index extortion_dum  border  round3  $controls_econ) (regress political_action_only econ_summary_index extortion_dum border  round3 $controls_econ), treat(extortion_dum) mediate(econ_summary_index) sims(2000) seed(1) level(95) vce(cluster id_survey)

matrix CI95_ep = J(2,3,.)
matrix colnames CI95_ep = ACME Direct Total
matrix CI95_ep[1, 1] = r(delta0lo)
matrix CI95_ep[1, 2] = r(zeta0lo)
matrix CI95_ep[1, 3] = r(taulo)
matrix CI95_ep[2, 1] = r(delta0hi)
matrix CI95_ep[2, 2] = r(zeta0hi)
matrix CI95_ep[2, 3] = r(tauhi)

coefplot matrix(medmean_ep), ci(CI95_ep CI90_ep) xline(0, lcolor(black)) title(Political Action Outcome; Economic Hardship Index) xtitle(Effect on Political Action Index) xlabel(-0.2(0.2)0.4) xscale(range(-0.2 0.4))
graph save med_econ_political.gph, replace
graph export med_econ_political.pdf, replace

graph combine med_econ_civic.gph med_econ_political.gph, ycommon xcommon rows(1)
graph export fig3_med_econ_combine.pdf, replace

****************************************************************************************
** Table A11: Extortion and Economic Hardship Mediation Analysis (mediation_econ_regs)
****************************************************************************************
eststo clear 
eststo: qui regress civic_action_only extortion_dum econ_summary_index $controls_econ border round3, vce(cluster id_survey)
gen sample_ec = 1 if e(sample) == 1
eststo: qui regress political_action_only extortion_dum econ_summary_index $controls_econ border round3, vce(cluster id_survey)
gen sample_ep = 1 if e(sample) == 1

eststo clear 
eststo: qui regress econ_summary_index extortion_dum $controls_econ border round3 if sample_ec == 1, vce(cluster id_survey)
eststo: qui regress civic_action_only extortion_dum econ_summary_index $controls_econ border round3 if sample_ec == 1, vce(cluster id_survey)
eststo: qui regress econ_summary_index extortion_dum $controls_econ border round3 if sample_ep == 1, vce(cluster id_survey)
eststo: qui regress political_action_only extortion_dum econ_summary_index $controls_econ border round3 if sample_ep == 1, vce(cluster id_survey)
esttab using table_a11_mediation_econ_regs.tex, label nogap b(2) se(2)  title(Extortion and Economic Hardship Mediation Analysis\label{mediation_econ})  mtitle("Econ Hardship Index" "Civic Action Index" "Econ Hardship Index" "Political Action Index") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent" "All models are OLS Linear Regressions" "Column 1 is first-stage model for civic outcome in Column 2" "Column 3 is first-stage model for political outcome in Column 4") replace



********************************************************************************
*** Table A12: Extortion and Engagement Items Disaggregated (ext_disaggregate)
********************************************************************************
local d_civic comm_meeting_panel volunteer_panel mentor_panel
local d_pol protest_panel affparty_panel vote_panel

eststo clear
foreach v in `d_civic' {
	eststo: qui regress `v' extortion_dum $controls border round3 if civic_action_only != .,  vce(cluster id_survey)
}

foreach v in `d_pol' {
	eststo: qui regress `v' extortion_dum $controls border round3 if political_action_only != .,  vce(cluster id_survey)
}

esttab using table_a12_ext_disaggregate.tex, label nogap b(2) se(2)  title(Extortion and Engagement Items Disaggregated\label{table:extdisag})  mtitle("Community Meeting" "Volunteer" "Mentor Youth" "Protest" "Affiliate Party" "Vote") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent" "All models are OLS Linear Regressions") replace


******************************************************************************************************
***	Table A13: Extortion and Engagement - Robustness Checks (mediation_fear_regs_robustness)
******************************************************************************************************
label variable zfear_count "Fear of Crime (Count)"

eststo clear 
eststo: qui regress civic_action_only extortion_dum r2anxious_cs r2reserved_cs r2critical_cs zfear_count $controls border round3, vce(cluster id_survey)
estadd local fixed "No", replace
eststo: qui regress political_action_only extortion_dum r2anxious_cs r2reserved_cs r2critical_cs zfear_count $controls border round3, vce(cluster id_survey)
estadd local fixed "No", replace
eststo: qui regress civic_action_only extortion_dum zfear_count $controls border round3 i.current_dpt_panel, vce(cluster id_survey)
estadd local fixed "Yes", replace
eststo: qui regress political_action_only extortion_dum zfear_count $controls border round3 i.current_dpt_panel, vce(cluster id_survey)
estadd local fixed "Yes", replace


esttab using table_a13_mediation_fear_regs_robustness.tex, label nogap b(2) se(2)  title(Extortion and Engagement - Robustness Checks\label{tab:robust})  mtitle("Civic Action Index" "Political Action Index" "Civic Action Index" "Political Action Index") drop(*current_dpt_panel) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("Robust standard errors clustered by respondent" "All models are OLS Linear Regressions") scalar("fixed Department Fixed Effects") replace

********************************************************************************
**** Table A14: Assault Not Correlated with Engagement (assault_regs)
********************************************************************************

eststo clear
eststo: qui regress civic_action_only assault_dum $controls border round3,  vce(cluster id_survey)
eststo: qui regress political_action_only assault_dum $controls border round3,  vce(cluster id_survey)
esttab using table_a14_assault_regs.tex, label nogap b(2) se(2)  title(Assault Not Correlated with Engagement\label{tab:assault})  mtitle("Civic Action Index" "Political Action Index") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) addnote("OLS Linear Regressions; Robust standard errors clustered by respondent") replace

********************************************************************************
***** Table A15: Romano-Wolf Adjusted p-values for Extortion Variable (rw_extortion)
********************************************************************************

* rwolf for multiple hypothesis testing of extortion on our 4 main outcomes
* Note: This procedure takes some time
gen extort = extortion_dum

rwolf civic_action_only political_action_only zecon_summary_index zfear_count, indepvar(extort) controls(border round3 $controls_econ) vce(cluster id_survey) cluster(id_survey) reps(1000) seed(1)
matrix rw = e(RW)
matrix colnames rw = "Model p-value" "Resample p-value" "Romano-Wolf p-value"
matrix rownames rw = "Civic Action Index" "Political Action Index" "Economic Hardship Index" "Fear of Crime"
esttab matrix(rw,fmt(3)) using table_a15_rw_extortion.tex, title("Romano-Wolf Adjusted p-values for Extortion Variable"\label{tab:rwolf}) replace

********************************************************************************
***  Table A3: Summary Statistics for Analysis Sample
********************************************************************************

gen summary_stats = 1 if sample_ec != . | sample_ep != . | sample_fc!= . | sample_fp!= . 

eststo clear
estpost summarize extortion_dum assault_dum civic_action_only comm_meeting_panel volunteer_panel mentor_panel political_action_only protest_panel affparty_panel vote_panel econ_summary_index econ_now hardship_guat monthly_income current_unemployed fearcount_general fear_any female age indigenous edu_highest_panel tattoo_yes children_us_panel children_gt_panel assets ln_timeus loc_social_cf border if summary_stats == 1

esttab using table_a3_sumstats_bjps.tex, label nogap cells("count(fmt(0)) mean(fmt(2)) sd(fmt(2)) min(fmt(1)) max(fmt(1))") title(Summary Statistics for Analysis Sample\label{tab:sumstats}) replace

 
********************************************************************************
** 					Additional Information Appendix
********************************************************************************
********************************************************************************
***  Figure A3: Democracy and Institutionalization index (top quartile) with 
***  returnees from the EU and USA
********************************************************************************
* Call the data
import delimited "$input/gt_extortion_rep_vdem.csv", clear 

* Create quartiles
xtile quartile_EU = eu_sum_2021, nq(4) 
xtile quartile_USA = us_2020, nq(4) 
gen topdep2 = (quartile_EU==4 | quartile_USA==4)

* Create logged vars
gen l_EU_sum_2021 = log(eu_sum_2021)
gen l_US_2020 = log(us_2020)

*Scatter institutionalization-EU quartile
preserve
keep if topdep2==1
sum v2xps_party
local ymean = r(mean)
sum l_EU_sum_2021, meanonly
local xmean = r(mean)
scatter v2xps_party l_EU_sum_2021 if topdep2==1 & country_name!="Total", mlabel(country_text_id) msymbol(none) xline(`xmean', lpattern(dash)) yline(`ymean', lpattern(dash)) || scatter v2xps_party l_EU_sum_2021 if country_text_id == "GTM", mlabel(country_text_id) msymbol(none) legend(off) xtitle("Deportations from EU" "(2021 - log)") ytitle("Party Institutionalization Index" "(V-Dem)") graphregion(color(white))

graph export "a3a_inst_quart_EU.pdf", replace
restore

*Scatter institutionalization USA quartile
preserve
keep if topdep2==1
sum v2xps_party
local ymean = r(mean)
sum l_US_2020, meanonly
local xmean = r(mean)
scatter v2xps_party l_US_2020 if topdep2==1 & country_name!="Total" , mlabel(country_text_id) msymbol(none) xline(`xmean', lpattern(dash)) yline(`ymean', lpattern(dash)) || scatter v2xps_party l_US_2020 if country_text_id == "GTM", mlabel(country_text_id) msymbol(none) legend(off) xtitle("Deportations from USA" "(2020 - log)") ytitle("Party Institutionalization Index" "(V-Dem)") graphregion(color(white)) 

graph export "a3c_inst_quart_USA.pdf", replace
restore

*Scatter Democracy EU quartile
preserve
keep if topdep2==1
sum v2x_polyarchy
local ymean = r(mean)
sum l_EU_sum_2021, meanonly
local xmean = r(mean)
scatter v2x_polyarchy l_EU_sum_2021 if topdep2==1 & country_name!="Total" , mlabel(country_text_id) msymbol(none) xline(`xmean', lpattern(dash)) yline(`ymean', lpattern(dash)) || scatter v2x_polyarchy l_EU_sum_2021 if country_text_id == "GTM", mlabel(country_text_id) msymbol(none) legend(off) xtitle("Deportations from EU" "(2021 - log)") ytitle("Democracy Index" "(V-Dem)") graphregion(color(white))

graph export "a3b_dem_quart_EU.pdf", replace
restore

*Scatter Democracy USA quartile
preserve
keep if topdep2==1
sum v2x_polyarchy
local ymean = r(mean)
sum l_US_2020, meanonly
local xmean = r(mean)
scatter v2x_polyarchy l_US_2020 if topdep2==1 & country_name!="Total" , mlabel(country_text_id) msymbol(none) xline(`xmean', lpattern(dash)) yline(`ymean', lpattern(dash)) || scatter v2x_polyarchy l_US_2020 if country_text_id == "GTM", mlabel(country_text_id) msymbol(none) legend(off) xtitle("Deportations from USA" "(2020 - log)") ytitle("Democracy Index" "(V-Dem)") graphregion(color(white)) 

graph export "a3d_dem_quart_USA.pdf", replace
restore



********************************************************************************
***  Table A16: Descriptive Statistics by Migratory Status LAPOP (2018/19)
********************************************************************************
* Call the data
import delimited "$input\gt_extortion_rep_lapop.csv", clear 

* Setting survey 
svyset upm, strata(estratopri)

* Labeling Vars
label var regist_dum "Registered to Vote"
label var vb2 "Voted last Elections (2015)"
label var will_vote "Willingness to Vote"
label var clien1n "Clientelism"
label var prot3 "Protest"
label var attend_church "Go to Church" 
label var attend_parents "Go to PTA"
label var attend_juntas "Go to community meetings"
label var attend_polpart "Go to Political Party Meetings"

* Calculating the descriptive statistics
global DESCVARS regist_dum vb2 will_vote clien1n prot3 attend_church attend_parents attend_juntas attend_polpart 
mata: mata clear

* First test of differences
local i = 1

foreach var in $DESCVARS {
    svy: reg `var' q14h
    outreg, keep(q14h)  rtitle("`: var label `var''") stats(b) ///
        noautosumm store(row`i')  starlevels(10 5 1) starloc(1)
    outreg, replay(diff) append(row`i') ctitles("",Difference ) ///
        store(diff) note("")
    local ++i
}
outreg, replay(diff)

* Then Summary statistics
local count: word count $DESCVARS
mat sumstat = J(`count',6,.)

local i = 1
foreach var in $DESCVARS {
    quietly: summarize `var' if q14h==0
    mat sumstat[`i',1] = r(N)
    mat sumstat[`i',2] = r(mean)
    mat sumstat[`i',3] = r(sd)
    quietly: summarize `var' if q14h==1
    mat sumstat[`i',4] = r(N)
    mat sumstat[`i',5] = r(mean)
    mat sumstat[`i',6] = r(sd)
    local i = `i' + 1
}
frmttable, statmat(sumstat) store(sumstat) sfmt(g,f,f,g,f,f)

*And export
outreg using "table_a16_balanceLapop_2018.tex", ///
    replay(sumstat) merge(diff) tex nocenter note("") fragment plain replace ///
    ctitles("", Control, "", "", Treatment, "", "", "" \ "", n, mean, sd, n, mean, sd, Diff) ///
    multicol(1,2,3;1,5,3) 
